package com.ease.util.reflection {

   import com.ease.util.Diagnostics;
   import com.ease.util.ProfilingManager;
   import com.ease.util.ReflectionUtil;

   /**
    * Represents the property level reflection info.
    */
   public class PropertyReflectionInfo extends MemberReflectionInfo {
      /**
       * The property type name.
       */
      public var typeName:String;

      /**
       * Whether this property is a variable.
       */
      public var isVariable:Boolean;

      private var _access:String;

      /**
       * The property access mode.
       * The value is one of <code>ReflectionUtil.ACCESS_READONLY
       * |ReflectionUtil.ACCESS_READWRITE|ReflectionUtil.ACCESS_WRITEONLY</code>
       */
      public function get access():String {
         return _access;
      }

      /** @private */
      public function set access(value:String):void {
         if (value == ReflectionUtil.ACCESS_READONLY) {
            _access = ReflectionUtil.ACCESS_READONLY;
         } else if (value == ReflectionUtil.ACCESS_WRITEONLY) {
            _access = ReflectionUtil.ACCESS_WRITEONLY;
         } else if (value == ReflectionUtil.ACCESS_READWRITE) {
            _access = ReflectionUtil.ACCESS_READWRITE;
         } else {
            Diagnostics.assert(false, "Unexpected access string: " + value);
         }
      }

      /**
       * @see ProfilingManager.getObjectSize.
       */
      override public function getNestedSize():int {
         var size1:int = super.getNestedSize();
         var size2:int = ProfilingManager.instance.getObjectSize(this.typeName);
         return  size1 + size2;
      }
   }

}